////////////////////////////////////////////////////////////////////////////
// 
//  time.hpp	---	time class
//
//
// Modification History:
//
//
////////////////////////////////////////////////////////////////////////////

#if !defined(TIME_HPP)
#define TIME_HPP

#include <time.h>
#include "strng.hpp"
#include "object.hpp"

class Time : public Object
{
private:

    enum { INVALID, VALID, UNLIMITED } status;
        
protected:

    long dt;                           // stored as time_t

    int isValid_time_t ( long aTime );

    int isValid_long ( long aDate );

    int isValid_mon_day_year ( int aMon, int aDay, int aYr );

    int isValid_hr_min_sec ( int aHr, int aMin, int aSec );

public:

    ///////////////////////////////////////////////////////////////////////
    // CONSTRUCTORS
    // sending an invalid value causes the time object to be invalid    
    // (ie. calling valid() will return FALSE                           
    ///////////////////////////////////////////////////////////////////////

    Time ();

    Time ( time_t aTime );              // Set from time_t
    
    Time ( int Mon, int Day, int Yr );  // Yr is CCYY

    Time ( int aMon, int aDay, int aYr, int aHr, int aMin, int aSec );

    isA()   { return OBJTYPE_TIME; }
    ///////////////////////////////////////////////////////////////////////
    // OPERATOR FUNCTIONS                                              
    // sending an invalid value causes the time object to be invalid     
    // (ie. calling valid() will return FALSE. All Years a CCYY          
    ///////////////////////////////////////////////////////////////////////

    Time &operator = (const Time &aTime);

    Time &operator = (const time_t aTime);

    ///////////////////////////////////////////////////////////////////////
    // "SET" FUNCTIONS                                              
    // sending an invalid value causes the time object to be invalid     
    // (ie. calling valid() will return FALSE. All Years a CCYY          
    ///////////////////////////////////////////////////////////////////////

    Time &setDate( int Mon, int Day, int Yr );
    
    Time &setDate( long aDate );

    Time &setTime( time_t aTime );

    Time &setTime( int Hr, int Min, int Sec );

    Time &set( int Mon, int Day, int Yr, int Hr,  int Min, int Sec );

    ///////////////////////////////////////////////////////////////////////
    // ACCESS FUNCTIONS                                                  
    // All Years a CCYY                                                  
    ///////////////////////////////////////////////////////////////////////

    String  asString( char *Format );

    Time &getDate( int *Mon, int *Day, int *Yr );
    
    Time &getTime( int *Hr, int *Min, int *Sec );

    Time &get( int *Mon, int *Day, int *Yr, int *Hr, int *Min, int *Sec );

    long   asYYMMDD();

    long   asCCYYMMDD();

    time_t asTime_t();

    int month();

    int monthDay();

    int year();                                    

    ///////////////////////////////////////////////////////////////////////
    // VALIDATION FUNCTIONS                                                  
    ///////////////////////////////////////////////////////////////////////

    int valid();

    int isUnlimited();

};

#endif

// End of File 'TIME.hpp'
